const user = {
	state: {
		userToken:uni.getStorageSync('userToken')||'',
		userInfo:uni.getStorageSync('userInfo')||'',
		appLanguage:uni.getStorageSync('appLanguage')||uni.getLocale(),
		languageEnum: {
			'en':'en_US',
			'zh-Hans':'zh_CN',
			'zh-Hant':'zh_HK',
			'id_ID':'id_ID',
			'ko_KR':'ko_KR',
			'th_TH':'th_TH',
			'vi_VN':'vi_VN',
			'pt_BR':'pt_BR',
			'es_ES':'es_ES',
			'ja':'ja_JP',
		}
	},
	mutations: {
		SET_userToken:(state, userToken)=>{
			state.userToken=userToken
		},
		SET_userInfo:(state, userInfo)=>{
			state.userInfo=userInfo
		},
		SET_changeLang(state, appLanguage) {
			uni.setStorageSync('appLanguage',appLanguage)
			state.appLanguage =appLanguage
		},
	},
	actions: { //异步操作mutation
		remove_userInfo({commit}, userInfo) {
			uni.removeStorageSync('userInfo');
			commit('SET_userInfo', userInfo)
		},
		set_userToken({commit}, userToken) {
			uni.setStorageSync('userToken', userToken);
			commit('SET_userToken', userToken)
		},
		set_userInfo({commit}, userInfo) {
			uni.setStorageSync('userInfo', userInfo);
			commit('SET_userInfo', userInfo)
		},
		remove_logout({commit},rememberPassword){
			uni.removeStorageSync('userInfo');
			uni.removeStorageSync('userToken');
			commit('SET_userToken', '')
			commit('SET_userInfo', '')
		},
		changeLang({
			commit
		}, appLanguage){
			console.log(appLanguage);
			uni.setLocale(appLanguage)
			commit('SET_changeLang',appLanguage)
		},
	}
}

export default user
